package org.qiuqiu.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.qiuqiu.dao.PersonMapper;
import org.qiuqiu.vo.Person;
import org.qiuqiu.vo.PersonExample;
import org.springframework.stereotype.Service;

@Service
public class PersonServiceImpl implements org.qiuqiu.service.PersonService {
    
    //@Resource默认是按照名称装配,找不到对应名字的则按照类型装配
    @Resource
    private PersonMapper pm;
    
    public PersonServiceImpl(){
	System.out.println("初始化PersonServiceImpl");
    }

    public PersonMapper getPm() {
        return pm;
    }
    
    public void setPm(PersonMapper pm) {
        this.pm = pm;
    }

    public Person login(String name, String password) {
	System.out.println(name+"  "+password);
	PersonExample pe = new PersonExample();
	pe.createCriteria().andNameEqualTo(name).andPasswordEqualTo(password);
	List<Person> list = pm.selectByExample(pe);
	if(list.size()>0){
	    return list.get(0);
	}else{
	    return null;
	}
    }
}
